package org.computate.form.item;

import com.itextpdf.text.Font;
import com.itextpdf.text.Font.FontFamily;
import com.itextpdf.text.Font.FontStyle;




public class PdfFont extends FormItem {
	
	private boolean serif;
	private int size;
	private boolean bold;
	private boolean italic;
	
	public PdfFont(boolean serif, int size, boolean bold, boolean italic) {
		this.serif = serif;
		this.size = size;
		this.bold = bold;
		this.italic = italic;
	}
	
	public PdfFont(boolean serif, int size) {
		this.serif = serif;
		this.size = size;
		this.bold = false;
		this.italic = false;
	}

	public boolean isSerif() {
		return serif;
	}

	public void setSerif(boolean serif) {
		this.serif = serif;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public boolean isBold() {
		return bold;
	}

	public void setBold(boolean bold) {
		this.bold = bold;
	}

	public boolean isItalic() {
		return italic;
	}

	public void setItalic(boolean italic) {
		this.italic = italic;
	}
	
	public Font getFont() {
		int style = FontStyle.NORMAL.ordinal();
		
		style |= bold ? FontStyle.BOLD.ordinal() : FontStyle.NORMAL.ordinal();
		style |= italic ? FontStyle.ITALIC.ordinal() : FontStyle.NORMAL.ordinal();
		
		return new Font(serif ? FontFamily.TIMES_ROMAN : FontFamily.HELVETICA, size, style);
	}
}
